<%@ Page PathInChannel="ajax/course/list{Ext}" RunAt="Execute" %>
<script language="c#" runat="server">
protected string Condition()
{
	StringBuilder condition = new StringBuilder(AliCMS.CourseModule.Alias.Course.IsDeleted + "=false AND " + AliCMS.CourseModule.Alias.Course.IsReleased + "=true");
	string and = " AND ";

	#region 类别
	if (!String.IsNullOrEmpty(Request.QueryString["CategoryID"]))
		condition.Append(and + AliCMS.CourseModule.Alias.Course.IncludeSubCategory + "=" + Request.QueryString["CategoryID"]);
	#endregion

	#region 类型
	if (!String.IsNullOrEmpty(Request.QueryString["MediaType"]))
		condition.Append(and + AliCMS.CourseModule.Alias.Course.MediaType + "='" + Request.QueryString["MediaType"] + "'");
	#endregion

	#region 关键字
	String keyword = Request.QueryString["Keyword"];
	if (!String.IsNullOrEmpty(keyword))
		condition.Append(and + "(" + AliCMS.CourseModule.Alias.Course.Name + " LIKE '%" + keyword + "%' or " + AliCMS.CourseModule.Alias.Course.Description + " LIKE '%" + keyword + "%')");
	#endregion
	
	return condition.ToString();
}

protected string Sort()
{
	string sort = String.Empty;
	switch (Request.QueryString["Order"])
	{
		case "1":
			sort = AliCMS.CourseModule.Alias.Course.InnerID + " DESC";
			break;
		case "2":
			sort = AliCMS.CourseModule.Alias.Course.HitCount + " DESC";
			break;
		default:
			sort = AliCMS.CourseModule.Alias.Course.InnerID + " DESC";
			break;
	}
	
	return sort;
}
</script>
<ali:List Mark="Course" Object="Course" Page="PageNumber" PageSize="Convert.ToInt32(Request.QueryString['PageSize'])" Condition="Condition()" Sort="Sort()">
	<ali:Record>
		<li>
			<a href="<%=BuildUrl(null, "course/view", "ID=" + InnerID)%>">
				<img src="<%=CommonSkinPath%>image/default.png" data-src="<%=Thumbnail%>">
				<h2><%=Name%></h2>
				<h3><label>价格：</label><%If Convert.ToDecimal(Price) == 0%><b>免费</b><%Else%><em><%=Convert.ToDecimal(Price).ToString("0.00")%></em><%EndIf%></h3>
			</a>
		</li>
	</ali:Record>
</ali:List>